<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
            "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>



<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<META name="GENERATOR" content="hevea 1.08">
<LINK rel="stylesheet" type="text/css" href="umsroot.css">
<TITLE>
How do I use ECLiPSe libraries in my programs?
</TITLE>
</HEAD>
<BODY >
<A HREF="umsroot014.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
<A HREF="umsroot008.html"><IMG SRC ="contents_motif.gif" ALT="Up"></A>
<A HREF="umsroot016.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
<HR>

<H2 CLASS="section"><A NAME="htoc31">3.7</A>&nbsp;&nbsp;How do I use ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> libraries in my programs?<A NAME="@default117"></A></H2>

A number of files containing library predicates are supplied with
the ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> system.
These predicates provide utility functions for general use.
They are usually installed in an ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> library directory (or
directories).
These predicates are either loaded automatically by ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> or may be
loaded &#8220;by hand&#8221;.<BR>
<BR>
During the execution of an ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> program, the system may dynamically
load files containing library predicates. When this happens, the user is
informed by a compilation or loading message.
It is possible to explicitly force this loading to occur by use
of the <A HREF="../bips/kernel/compiler/lib-1.html"><B>lib/1</B></A><A NAME="@default118"></A> or
<A HREF="../bips/kernel/modules/use_module-1.html"><B>use_module/1</B></A><A NAME="@default119"></A> predicates.
e.g., to load the library
called <TT>lists</TT>, use one of the following goals:
<BLOCKQUOTE CLASS="quote">
<PRE CLASS="verbatim">
lib(lists)
use_module(library(lists))
</PRE></BLOCKQUOTE>
This will load the library file unless it has been already loaded.
In particular, a program can ensure that a given library is loaded when it
is compiled, by including an appropriate directive in the source, e.g.,
<TT>:- lib(lists).</TT><BR>
<BR>
Library files are found by searching the library path and by appending
a suffix to the library name.
<A NAME="@default120"></A>
<A NAME="@default121"></A>
The search path used when loading libraries is
specified by the global flag <B>library_path</B> using the
<A HREF="../bips/kernel/env/get_flag-2.html"><B>get_flag/2</B></A><A NAME="@default122"></A> and
<A HREF="../bips/kernel/env/set_flag-2.html"><B>set_flag/2</B></A><A NAME="@default123"></A> predicates.
This flag contains a list of strings containing the pathnames of the
directories to be searched when loading a library file.
User libraries may be be added to the system simply by copying the
desired file into the ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> library directory.
Alternatively the <B>library_path</B> flag may be updated to point
at a number of user specific directories. The following example illustrates
how a directive may be added to a file to add a user-defined library in front
of any existing system libraries.
<BLOCKQUOTE CLASS="quote">
<PRE CLASS="verbatim">
?- get_flag(library_path,Path),
   set_flag(library_path, ["/home/myuser/mylibs" | Path]).
</PRE></BLOCKQUOTE>
The UNIX environment variable <TT>ECLIPSELIBRARYPATH</TT><A NAME="@default124"></A> may also be used
to
specify the initial setting of the library path.
The syntax is similar to the syntax of the UNIX PATH variable, i.e.,
a list of directory names separated by colons.
The directories will be prepended to the standard library path in the
given order.<BR>
<BR>
<HR>
<A HREF="umsroot014.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
<A HREF="umsroot008.html"><IMG SRC ="contents_motif.gif" ALT="Up"></A>
<A HREF="umsroot016.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
</BODY>
</HTML>
